Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added bulk create method for posting 1+ N tasks in single api call #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Stephenitis
Copy link
Contributor

The api allows for bulk posting of tasks but the ruby but the tasks.create method was not changeable to fit this behavior without possibly breaking code where previous users would have an array as their payload rather than an array of payloads.

p client.tasks.bulk_create('hello_ruby', Array.new(100) {|i| {:hello => "world"} }, {:cluster => "mem1"} )

@ysadka
Copy link

ysadka commented Jan 31, 2015

👍

@Stephenitis
Copy link
Contributor Author

@sunloverz can you review implementation?

def tasks_bulk_create(code_name, params = [], options = {})
IronCore::Logger.debug 'IronWorkerNG', "Calling tasks.bulk_create_legacy with code_name='#{code_name}', params='#{params.to_s}' and options='#{options.to_s}'"

res = @api.tasks_bulk_create(code_name, params.is_a?(Array) ? params : params.to_json, options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me. How about passing just params without checking params.is_a?(Array), if you pass string it will raise en error NoMethodError: undefined method `map!' for String

@sunloverz
Copy link
Contributor

@Stephenitis any updates here?

@ysadka
Copy link

ysadka commented Mar 23, 2015

@Stephenitis ping. wanna get this merged?

@treeder
Copy link
Contributor

treeder commented Mar 23, 2015

Can you guys get this into iron_worker_ruby too (nearly the same code, was copied over). https://github.com/iron-io/iron_worker_ruby

NG will probably be deprecated soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants